<!DOCTYPE html>
<!--suppress ALL-->
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.css}">
    <script th:src="@{/jquery/jquery-3.5.1.min.js}"></script>
</head>
<body>

    <table class="table table-bordered table-responsive" style="margin-top: 30px">
        <tr>
            <td colspan="7">
                <a th:href="@{/goods/goodsList}" class="btn btn-default">返回主页</a>
            </td>
        </tr>
        <tr>
            <th>#</th>
            <th>商品名称</th>
            <th>商品类型</th>
            <th>商品数量</th>
            <th>订单状态</th>
            <th>下单时间</th>
            <th>操作</th>
        </tr>
        <tr th:each="order : ${pageInfo.list}">
            <th><input type="checkbox" th:value="${order.goodsId}"></th>
            <th th:text="${order.gname}">iphone 4</th>
            <th th:text="${order.typeName}">手机</th>
            <th th:text="${order.orderNum}">100</th>
            <th th:text="${order.status}">100</th>
            <th th:text="${#dates.format(order.createDate, 'yyyy-MM-dd HH:mm:ss')}">100</th>
            <th><button type="button" th:onclick="|removeOrder(${order.orderId})|" class="btn btn-warning">取消订单</button></th>
        </tr>
        <tfoot>
        <tr >
            <td colspan="7" align="center">
                <ul class="pagination">
                    <li><a th:href="@{/order/orderList(now=${pageInfo.prePage})}">上一页</a></li>
                    <li><a th:each="page : ${pageInfo.getNavigatepageNums()}" th:text="${page}" th:href="@{/order/orderList(now=${page})}">1</a></li>
                    <li><a th:href="@{/order/orderList(now=${pageInfo.nextPage})}">下一页</a></li>
                </ul>
            </td>
        </tr>

        </tfoot>
    </table>


    <script th:src="@{/bootstrap/js/bootstrap.js}"></script>
    <script th:inline="javascript">
        function removeOrder(orderId) {
            let url = /*[[@{/order/removeOrder}]]*/;
            let params = "orderId=" + orderId;
            $.post(url, params, function (data) {
                if (data == "1") {
                    alert("取消成功");
                    window.location.href = /*[[@{/order/orderList(now=${pageInfo.getPageNum()})}]]*/;
                } else {
                    alert("取消失败");
                }
            })
        }
    </script>
</body>
</html>